routine [ ]
Documentation for routine [ ]
assembled from the following types:
language documentation Operators
From Operators
(Operators) circumfix [ ]
The Array constructor returns an itemized Array that does not flatten in list context. Check this:
say .perl for [3,2,[1,0]]; # OUTPUT: «32$[1, 0]»
This array is itemized, in the sense that every element constitutes an item, as shown by the $
preceding the last element of the array, the (list) item contextualizer.
language documentation Operators
From Operators
(Operators) postcircumfix [ ]
sub postcircumfix:<[ ]>(, **,:, :, :, :, :, :)
Universal interface for positional access to zero or more elements of a @container, a.k.a. "array indexing operator".
my = 'a' .. 'z';say [0]; # OUTPUT: «a»say [1]; # OUTPUT: «b»say []; # OUTPUT: «z»say [100]:exists; # OUTPUT: «False»say [15, 4, 17, 11].join; # OUTPUT: «perl»say [23 .. *].perl; # OUTPUT: «("x", "y", "z")»[1, 2] = "B", "C";say [0..3].perl # OUTPUT: «("a", "B", "C", "d")»
See Subscripts, for a more detailed explanation of this operator's behavior and for how to implement support for it in custom types.